<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/core" prefix="c"%>
<%@ taglib uri="/tags/fmt" prefix="fmt"%>
<%@ taglib uri="/WEB-INF/tld/security.tld" prefix="s" %>

<script type="text/javascript" src="js/utils.js"></script>
<script type="text/javascript">
function submitPurchaseProgramQuery(form, orderField, orderType){
		form.orderField.value = orderField;
		form.orderType.value = orderType;
		form.action = "listPurchaseProgramQuery.do";
		if (validSubmit){
			form.submit();
		} else {
			alert('<bean:message key="warning.message.common.processing"/>');
		}
	}
</script>
<html:form action="/listPurchaseProgramQuery" method="POST">
	<html:hidden property="orderField"/>
	<html:hidden property="orderType"/>
	<table align="center" width="80%" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
		<tr>
			<td colspan="7" class="titulocolumna" align="center"><bean:message key="menu.module.corn.purchase.program"/></td>
		</tr>
		<tr>
			<td class="etiqueta"><bean:message key="label.program.purchase.initdate"/></td>
			<td class="etiqueta_campo">
				<html:select property="biWeekInit" style="width:160px" styleClass="campo_texto" >
	      						<html:optionsCollection  name="biWeekInitListViews"  value="biweekPeriodId" label="description" />
							</html:select>
			</td>
			<td class="etiqueta"><bean:message key="label.program.purchase.finishdate"/></td>
			<td class="etiqueta_campo">						
				<html:select property="biWeekFinish" style="width:160px" styleClass="campo_texto">
	      						<html:optionsCollection name="biWeekFinishListViews"  value="biweekPeriodId" label="description"/>
							</html:select>	
				
			</td>
			<td class="etiqueta"><bean:message key="label.transports.query.transport"/></td>
			<td class="etiqueta_campo">
				<html:select property="transportIdFilter" style="width:160px" styleClass="campo_texto">
					<html:option value="-1"><bean:message key="label.program.purchase.selectanoption"/></html:option>
	      						<html:optionsCollection name="transportListViews" value="transportIdentifier" label="transportDescription"/>
							</html:select>	
			</td>
			<td align="center" class="columnadatoPar">
				<input type="submit" value="<bean:message key="label.common.query"/>"  class="boton"/>
			</td>
		</tr>
	</table>
</html:form>
<table align="center" width="80%" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
	<tr>
		<td class="titulocolumna" align="center">
			<s:entidad nombreCortoMod="PROC" nombreCortoSub="PURPROG" nombreCortoEnt="NEW" permiso="ADMINISTRACION">
				<html:link action="/showAddPurchaseOrder.do"><img alt="<bean:message key="label.common.add"/> <bean:message key="label.purchaseorder.name"/>" src="images/nuevo.gif" border="0"></html:link>
				<html:link action="/purchaseProgramGoGenerate"><img alt="<bean:message key="label.common.generator"/>" src="images/cog.png" border="0"></html:link>
			</s:entidad>
		</td>
		
		<td class="titulocolumna" align="center">
			<a href="#>" onclick="return submitPurchaseProgramQuery(document.PurchaseProgramQueryForm, 0,'<c:choose><c:when test="${previousOrderField == 0 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.purchase.program.period"/>
				<c:choose>
					<c:when test="${previousOrderField == 0 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 0 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>		
		</td>
		
		<td class="titulocolumna" align="center">
			<a href="#>" onclick="return submitPurchaseProgramQuery(document.PurchaseProgramQueryForm, 1, '<c:choose><c:when test="${previousOrderField == 1 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.purchase.program.bno"/>
				<c:choose>
					<c:when test="${previousOrderField == 1 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 1 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>	
		</td>
		
		<td class="titulocolumna" align="center">
			<a href="#>" onclick="return submitPurchaseProgramQuery(document.PurchaseProgramQueryForm, 2, '<c:choose><c:when test="${previousOrderField == 2 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.purchase.program.futures"/>
				<c:choose>
					<c:when test="${previousOrderField == 2 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 2 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>	
		</td>
		
		<td class="titulocolumna" align="center">
			<a href="#>" onclick="return submitPurchaseProgramQuery(document.PurchaseProgramQueryForm, 3, '<c:choose><c:when test="${previousOrderField == 3 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.purchase.progrma.tons"/>
				<c:choose>
					<c:when test="${previousOrderField == 3 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 3 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>	
		</td>
		
		<td class="titulocolumna" align="center">
			<a href="#>" onclick="return submitPurchaseProgramQuery(document.PurchaseProgramQueryForm, 4, '<c:choose><c:when test="${previousOrderField == 4 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.purchase.program.price.bu"/>
				<c:choose>
					<c:when test="${previousOrderField == 4 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 4 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>	
		</td>
		
		<td class="titulocolumna" align="center">
			<a href="#>" onclick="return submitPurchaseProgramQuery(document.PurchaseProgramQueryForm, 5, '<c:choose><c:when test="${previousOrderField == 5 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.purchase.program.base.bu"/>
				<c:choose>
					<c:when test="${previousOrderField == 5 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 5 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>	
		</td>
		
		<td class="titulocolumna" align="center">
			<a href="#>" onclick="return submitPurchaseProgramQuery(document.PurchaseProgramQueryForm, 6, '<c:choose><c:when test="${previousOrderField == 6 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.purchase.program.price.us.bu"/>
				<c:choose>
					<c:when test="${previousOrderField == 6 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 6 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>	
		</td>
		
		<td class="titulocolumna" align="center">
			<a href="#>" onclick="return submitPurchaseProgramQuery(document.PurchaseProgramQueryForm, 7, '<c:choose><c:when test="${previousOrderField == 6 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.purchase.program.price.us.tm"/>
				<c:choose>
					<c:when test="${previousOrderField == 7 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 7 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>	
		</td>
		
		<td class="titulocolumna" align="center">
			<a href="#>" onclick="return submitPurchaseProgramQuery(document.PurchaseProgramQueryForm, 8, '<c:choose><c:when test="${previousOrderField == 6 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.purchase.program.val.real.fut"/>
				<c:choose>
					<c:when test="${previousOrderField == 8 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 8 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>	
		</td>
		
		<td class="titulocolumna" align="center">
			<a href="#>" onclick="return submitPurchaseProgramQuery(document.PurchaseProgramQueryForm, 9, '<c:choose><c:when test="${previousOrderField == 6 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.purchase.program.real.plus.base"/>
				<c:choose>
					<c:when test="${previousOrderField == 9 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 9 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>	
		</td>
		
		<td class="titulocolumna" align="center">
			<a href="#>" onclick="return submitPurchaseProgramQuery(document.PurchaseProgramQueryForm, 10, '<c:choose><c:when test="${previousOrderField == 6 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.purchase.program.c.real.tm"/>
				<c:choose>
					<c:when test="${previousOrderField == 10 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 10 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>	
		</td>
		<td width="20" class="titulocolumna" align="center">
			&nbsp;
		</td>
		<td width="20" class="titulocolumna" align="center">
			&nbsp;
		</td>
		<td width="20" class="titulocolumna" align="center">
			&nbsp;
		</td>
	</tr>
	<logic:notEmpty name="purchaseProgramListViews">
		<logic:iterate id="row" name="purchaseProgramListViews" indexId="int_i">
			<tr class="<%=((int_i.intValue()%2)==0?"columnadatoPar":"columnadatoNon")%>">
				<html:hidden name="row" property="purchaseOrderId"/>				
				<td align="center">
					<s:entidad nombreCortoMod="PROC" nombreCortoSub="PURPROG" nombreCortoEnt="EDIT" permiso="ADMINISTRACION">
						<html:link action="/showEditPurchaseOrder.do" paramId="purchaseOrderId" paramName="row" paramProperty="purchaseOrderId"> <img alt="<bean:message key="common.edit"/> <bean:write name="row" property="bNo"/><bean:write name="row" property="bnoNumber"/>" src="images/modificar.gif" border="0"> </html:link>
					</s:entidad>
				</td>
				<td align="left"><bean:write name="row" property="period"/></td>
				<td align="left"><bean:write name="row" property="bNo"/><bean:write name="row" property="bnoNumber"/></td>
				<td align="right"><c:if test="${row.futures != 0.0}"><bean:write name="row" property="futures" format="###,###,##0.000"/></c:if></td>
				<td align="right">
					<logic:notEqual name="row" property="sapAssigned" value="-1">
						<bean:write name="row" property="tons" format="###,###,##0.000"/>
					</logic:notEqual>
				</td>
				<td align="right">
					<logic:notEqual name="row" property="bushelPriceAssigned" value="-1">
						<bean:write name="row" property="priceBu" format="###,###,##0.0000"/>
					</logic:notEqual>
				</td>
				<td align="right">
					<bean:write name="row" property="baseBu"  format="#####,###,##0.0000"/>
				</td>
				<td align="right">
					<logic:notEqual name="row" property="bushelPriceAssigned" value="-1">
						<bean:write name="row" property="priceUsBu"  format="###,###,##0.0000"/>
					</logic:notEqual>
				</td>
				<td align="right">
					<logic:notEqual name="row" property="bushelPriceAssigned" value="-1">
						<bean:write name="row" property="priceUsTm"  format="###,###,##0.0000"/>
					</logic:notEqual>
				</td>										
				<td align="right">
					<logic:notEqual name="row" property="futureAssigned" value="-1">
						<bean:write name="row" property="valRealFut"  format="###,###,##0.0000"/>
					</logic:notEqual>
				</td>
				<td align="right">
					<logic:notEqual name="row" property="futureAssigned" value="-1">
						<bean:write name="row" property="valBase"  format="###,###,##0.0000"/>
					</logic:notEqual>
				</td>
				<td align="right">
					<logic:notEqual name="row" property="futureAssigned" value="-1">
						<bean:write name="row" property="cRealTm"  format="###,###,##0.0000"/>
					</logic:notEqual>
				</td>
				<td align="center">
					<s:entidad nombreCortoMod="PROC" nombreCortoSub="PURPROG" nombreCortoEnt="PURLINK" permiso="ADMINISTRACION">
						<logic:notEqual name="row" property="sapAssigned" value="-1">
							<html:link action="/goTransitionCorn.do" paramId="purchaseOrderId" paramName="row" paramProperty="purchaseOrderId"> <img alt="<bean:message key="label.purchaseorder.purchaseoffuture.assignation.title"/> <bean:write name="row" property="bNo"/><bean:write name="row" property="bnoNumber"/>" src="images/attach.png" border="0"></html:link>
						</logic:notEqual>
						<logic:equal name="row" property="sapAssigned" value="-1">
							<html:link action="/goTransitionCorn.do" paramId="purchaseOrderId" paramName="row" paramProperty="purchaseOrderId"> <img alt="<bean:message key="label.purchaseorder.purchaseoffuture.assignation.title"/> <bean:write name="row" property="bNo"/><bean:write name="row" property="bnoNumber"/>" src="images/attach_disabled.png" border="0"></html:link>
						</logic:equal>
					</s:entidad>
				</td>
				<td align="center">
					<s:entidad nombreCortoMod="PROC" nombreCortoSub="PURPROG" nombreCortoEnt="FUTULINK" permiso="ADMINISTRACION">
						<html:link action="/assignPurchaseOfFutures.do" paramId="purchaseOrderId" paramName="row" paramProperty="purchaseOrderId">
							<logic:notEqual name="row" property="futureAssigned" value="-1">
								<img alt="<bean:message key="label.purchaseorder.purchaseoffuture.assignation.title"/> <bean:write name="row" property="bNo"/><bean:write name="row" property="bnoNumber"/>" src="images/attach_future.png" border="0">
							</logic:notEqual>
							<logic:equal name="row" property="futureAssigned" value="-1">
								<img alt="<bean:message key="label.purchaseorder.purchaseoffuture.assignation.title"/> <bean:write name="row" property="bNo"/><bean:write name="row" property="bnoNumber"/>" src="images/attach_future_disabled.png" border="0">
							</logic:equal>
						</html:link>
					</s:entidad>
				</td>
				<td align="center">
					<s:entidad nombreCortoMod="PROC" nombreCortoSub="PURPROG" nombreCortoEnt="DELETE" permiso="ADMINISTRACION">
						<a href="#>" onclick="if( confirmDelete('<bean:write name="row" property="bNo"/><bean:write name="row" property="bnoNumber"/>') )location.href='delPurchaseProgram.do?purchaseOrderId=<bean:write name="row" property="purchaseOrderId"/>';">
							<img alt="<bean:message key="common.delete"/> <bean:write name="row" property="bNo"/><bean:write name="row" property="bnoNumber"/>" src="images/eliminar.jpg" border="0">
						</a>
					</s:entidad>
				</td>
			</tr>
		</logic:iterate>
	</logic:notEmpty>
</table>
<br />
<br />